#include "ImgTxtWriter.h"
using namespace std;
/*******************************************************************/
CImgTxtWriter::CImgTxtWriter(void)
{
	//m_font = new CvFont();
	cvInitFont(&m_font,CV_FONT_HERSHEY_TRIPLEX, 0.6, 0.6 );
	m_colorMap["RED"]= CV_RGB(255,0,0);
	m_colorMap["GREEN"]= CV_RGB(0,255,0);
	m_colorMap["BLUE"]= CV_RGB(0,0,255);
	m_colorMap["YELLOW"]= CV_RGB(255,255,0);
	m_colorMap["MAGENTA"]= CV_RGB(255,0,255);
	m_colorMap["CYAN"]= CV_RGB(0,255,255);
	m_colorMap["WHITE"]= CV_RGB(255,255,255);
	m_colorMap["BLACK"]= CV_RGB(0,0,0);
	m_colorMap["GRAY"]= CV_RGB(128,128,128);
	m_color = CV_RGB(255,255,255);
	m_location = cvPoint(0,0); 
}
/*******************************************************************/
CImgTxtWriter::~CImgTxtWriter(void)
{
//	if( NULL != &m_font )
//		cvRelease(&m_font);
}
/*******************************************************************/
IplImage* CImgTxtWriter::WriteText( string text, IplImage* img)
{
	if( NULL != img )
	{
		cvPutText( img, text.c_str(), m_location, &m_font, m_color );
	}
	return img; 
}
/*******************************************************************/
IplImage* CImgTxtWriter::WriteText(string text, IplImage* img, string color)
{
	if( NULL != img )
	{
		cvPutText( img, text.c_str(), m_location, &m_font, m_colorMap[color] );
	}
	return img; 
}
/*******************************************************************/
IplImage* CImgTxtWriter::WriteText(string text, IplImage* img, CvPoint pt )
{
	if( NULL != img )
	{
		cvPutText( img, text.c_str(), pt, &m_font, m_color );
	}
	return img;
}
/*******************************************************************/
IplImage* CImgTxtWriter::WriteText(string text, IplImage* img, string color, CvPoint pt )
{
	if( NULL != img )
	{
		cvPutText( img, text.c_str(), pt, &m_font, m_colorMap[color] );
	}
	return img; 
}
/*******************************************************************/
void CImgTxtWriter::AddColor( string name, CvScalar c)
{
	m_colorMap[name]=c;
}
/*******************************************************************/
void CImgTxtWriter::SetColor( string name )
{
	m_color = m_colorMap[name];
}
/*******************************************************************/
CvScalar CImgTxtWriter::GetColor( void )
{
	return m_color;
}
/*******************************************************************/
void CImgTxtWriter::SetLocation( CvPoint pt )
{
	m_location = pt;
}
/*******************************************************************/
CvPoint CImgTxtWriter::GetLocation( void )
{
	return m_location;
}
/*******************************************************************/
